const a = async function (node, ...args) {
  const [
    {
      memory,
      transfer: { showContextMenu = false },
    },
    {
      $tree,
      dc: { http, open, reload },
      helper: { treeToList },
      xe: { clone, get },
    },
  ] = args.slice(-2);
  if (!showContextMenu) return [];
  return [
    {
      icon: "bi:plus-lg",
      label: "同步一体化企业",
      handler: async function () {
        const layout = { id: "1797803358876741634" };
        const modal = {
          title: "同步一体化企业",
          width: "55vw",
          minHeight: document.body.clientHeight * 0.75,
          defaultFullscreen: false,
          destroyOnClose: false,
          maskClosable: false,
          open: true,
          showOkBtn: false,
          showCancelBtn: true,
          afterClose: function () {
            reload();
          },
        };
        const checkkeyList =
          treeToList($tree.getTreeData()).map((i) => i.guid) || [];
        const inner = {};
        open({ inner, layout, modal, transfer: { checkkeyList } });
      },
    },
    {
      icon: "bi:trash3",
      label: "删除",
      handler: async function () {
        console.log("删除: ", $tree, node);
        const guids = treeToList([node.dataRef])
          .map(function ({ guid }) {
            return guid;
          })
          .join(",");
        console.log("guids: ", guids);
        await http.form({
          url: "/qyk/enterprise/deleteByGuid",
          data: { guids },
        });
        $tree.deleteNodeByKey(node.key);
      },
    },
    {
      icon: "material-symbols:sync",
      label: "同步所有一体化企业",
      handler: async function () {
        await http.form({ url: "/qyk/enterprise/synAll" });
        reload();
      },
    },
  ];
};

const a1 = async function (node, ...args) {
  const [
    {
      memory,
      transfer: { showContextMenu = false },
    },
    {
      $tree,
      dc: { http, open, reload },
      helper: { treeToList },
      xe: { clone, get },
    },
  ] = args.slice(-2);
  if (!showContextMenu) return [];
  return [
    {
      icon: "bi:plus-lg",
      label: "同步一体化企业",
      handler: async function () {
        const layout = { id: "1789254255686307841" };
        const modal = {
          title: "同步一体化企业",
          width: "55vw",
          minHeight: document.body.clientHeight * 0.75,
          defaultFullscreen: false,
          destroyOnClose: false,
          maskClosable: false,
          open: true,
          showOkBtn: false,
          showCancelBtn: true,
          afterClose: function () {
            reload();
          },
        };
        const checkkeyList =
          treeToList($tree.getTreeData()).map((i) => i.guid) || [];
        const inner = {};
        open({ inner, layout, modal, transfer: { checkkeyList } });
      },
    },
    {
      icon: "bi:trash3",
      label: "删除",
      handler: async function () {
        console.log("删除: ", $tree, node);
        const guids = treeToList([node.dataRef])
          .map(function ({ guid }) {
            return guid;
          })
          .join(",");
        console.log("guids: ", guids);
        await http.form({
          url: "/nyk/enterprise/deleteByGuid",
          data: { guids },
        });
        $tree.deleteNodeByKey(node.key);
      },
    },
    {
      icon: "material-symbols:sync",
      label: "同步所有一体化企业",
      handler: async function () {
        await http.form({ url: "/nyk/enterprise/synAll" });
        reload();
      },
    },
  ];
};
